//不同路径
//测试链接：https://leetcode.cn/problems/unique-paths/
public class UniquePaths {
    public int uniquePaths(int m, int n) {
        int[][] memo = new int[m + 1][n + 1];
        return dfs(m, n, memo);
    }

    public int dfs(int i, int j, int[][] memo) {
        if (memo[i][j] != 0) {
            return memo[i][j];
        }
        if (i == 0 || j == 0)
            return 0;
        if (i == 1 && j == 1) {
            memo[i][j] = 1;
            return 1;
        }
        memo[i][j] = dfs(i - 1, j, memo) + dfs(i, j - 1, memo);
        return memo[i][j];
    }
}
